package com.woniuxy.propertyjava.service.impl;

import com.woniuxy.propertyjava.dao.BuyMedicinesDao;
import com.woniuxy.propertyjava.entity.BuyMedicines;
import com.woniuxy.propertyjava.entity.PageBean;
import com.woniuxy.propertyjava.service.BuyMedicinesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Service
public class BuyMedicinesServiceImpl implements BuyMedicinesService {
    @Resource
    BuyMedicinesDao buyMedicinesDao;

    //根据id查询数据
    @Override
    public BuyMedicines getqueryById(Integer bmid) {
        return this.buyMedicinesDao.queryById(bmid);
    }

    //分页查询
    @Override
    public PageBean<BuyMedicines> getqueryAllMedicines(BuyMedicines buyMedicines,int pageIndex, int pageSize) {
        PageBean<BuyMedicines> pageBean=new PageBean<>();
        pageBean.setBeanList(buyMedicinesDao.queryAllMedicines(buyMedicines,pageIndex,pageSize));
        pageBean.setPageIndex(pageIndex);
        pageBean.setPageSize(pageSize);
        pageBean.setTotalRecode(buyMedicinesDao.count());
        return pageBean;
    }

    //添加
    @Override
    public void getinsert(BuyMedicines buyMedicines) {
        buyMedicinesDao.insert(buyMedicines);
    }

    //删除
    @Override
    public void getdeleteById(Integer bmid) {
        buyMedicinesDao.deleteById(bmid);
    }

    //修改
    @Override
    public void getupdate(BuyMedicines buyMedicines) {
        buyMedicinesDao.update(buyMedicines);
    }
}
